<?php
/**
 * 解密算法类
 * 
 * @example 
 * 			$a = new Decrypt("passward","key");
 * 			echo $a->returnCode();
 * @exception 输入字符串是已经被加密的密文。密匙需要和加密的密匙相同；
 * @package Safety/Acthcode
 * @link www.sampeng.cn
 * @version $ID:Decrypt $Time:2008-11-22 15:48:05 SamPeng
 * @copyright SamPeng & Comsenz Inc
 */
class Decrypt extends Code {
	protected function codeString(){
		$this->keyc =self::CKEY_LENGTH  ? (substr($this->string, 0, self::CKEY_LENGTH )) : '';

		$this->cryptkey = $this->keya.md5($this->keya.$this->keyc);
		$this->key_length = strlen($this->cryptkey);
		
		$this->string = base64_decode(substr($this->string,self::CKEY_LENGTH ));
	}
	
	public function returnCode(){
		if((substr($this->result, 0, 10) == 0 || substr($this->result, 0, 10) - time() > 0) && substr($this->result, 10, 16) == substr(md5(substr($this->result, 26).$this->keyb), 0, 16)) {
			return substr($this->result, 26);
		} else {
			return '';
		}		
	}
}
?>